package com.woniuxy.mesboot.service.impl;

import com.woniuxy.mesboot.entity.SysMenu;
import com.woniuxy.mesboot.mapper.SysMenuMapper;
import com.woniuxy.mesboot.service.MenuService;
import com.woniuxy.mesboot.vo.MenuVO;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author ：lisir
 * @date ：Created in 2023/5/24 16:52
 * @description：TODO
 */
@Service
public class MenuServiceImpl implements MenuService {

    @Resource
    private SysMenuMapper menuMapper;

    @Override
    public List<MenuVO> selectMenuByName(String userName, Integer parentId) {
        List<MenuVO> menuVOS = menuMapper.selectMenuByName(userName, parentId);
        if (menuVOS != null) {
            for (MenuVO menuVO : menuVOS) {
                List<MenuVO> menuVOS1 = selectMenuByName(userName, menuVO.getMenuId());
                menuVO.setChildren(menuVOS1);
            }
        }
        return menuVOS;
    }

    @Override
    public List selectAll() {
        return menuMapper.selectAll();
    }

    @Override
    public int deleteByPrimaryKey(Long id) {
        return menuMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int insertSelective(SysMenu record) {
        return menuMapper.insertSelective(record);
    }

    @Override
    public SysMenu selectByPrimaryKey(Long id) {
        return menuMapper.selectByPrimaryKey(id);
    }

    @Override
    public int updateByPrimaryKeySelective(SysMenu record) {
        return menuMapper.updateByPrimaryKeySelective(record);
    }
}
